﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using MyOA.Model;
using System.Data.SqlClient;


namespace MyOA.DAL
{
    public class PersonNoteService
    {
        DBHelper db = new DBHelper();
        /// <summary>
        /// 根据登陆号来获取便签信息
        /// </summary>
        /// <param name="loginId">登陆号</param>
        /// <returns>返回便签信息</returns>
        public IList<MyNote> getMyNoteByLoginId(string loginId)
        {
            IList<MyNote> notes = new List<MyNote>();
            using (SqlDataReader reader=db.getDataReader("sp_getMyNotesByLoginId",new SqlParameter("@loginId",loginId)))
            {
                while (reader.Read())
                { 
                    MyNote note = new MyNote();
                    note.NoteId = (int)reader[0];
                    note.NoteTitle = (string)reader[1];
                    note.NoteContent = (string)reader[2];
                    note.CreateTime = (DateTime)reader[3];
                    note.CreateUser.UserId = (int)reader[4];

                    notes.Add(note);
                }
            }
            db.CloseConnection();
            
            return notes;
        }
    }
}
